﻿using StackExchange.Redis;
using SvGame.Objects;
using System.Numerics;

namespace SvGame.Logic;

public static partial class GameLogic
{
    public static void Chat(this IRole me, ChatChannel chatChannel, string text)
    {
        var ntf = new G2CNtfChatMessage();
        ntf.Channel = chatChannel;
        ntf.Text = text;
        ntf.TicksSend = DateTime.Now.Ticks;
        ntf.SenderName = me.Name;
        switch (chatChannel)
        {
            case ChatChannel.Chat:
                Broadcast(ntf);
                break;
            case ChatChannel.Rumor:
                Broadcast(ntf);
                break;
            case ChatChannel.Room:
                BroadcastWhere(ntf, (p) => { return p.RoomUid == me.Room.Uid; });
                break;
            case ChatChannel.Family:
                if (!me.Family.IsNullOrEmpty())
                {
                    BroadcastWhere(ntf, (p) => { return p.Family == me.Family; });
                }
                break;
            case ChatChannel.Guild:
                if (!me.Guild.IsNullOrEmpty())
                {
                    BroadcastWhere(ntf, (p) => { return p.Guild == me.Guild; });
                }
                break;
            case ChatChannel.Tell:
                break;
            default:
                break;
        }
    }
    public static void Chat(this IRole me, C2GChatSend req)
    {
        Chat(me, req.Channel, req.Text);
    }
}
